package com.simplemall.micro.serv.tel.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.simplemall.micro.serv.common.bean.telbook.TelBookInfo;
import com.simplemall.micro.serv.common.constant.SystemConstants;
import com.simplemall.micro.serv.tel.service.TelBookInfoService;

@RestController
@RequestMapping("/telBookInfo")
public class TelBookInfoController {

	@Autowired
	TelBookInfoService telBookInfoService;
	
	/**
	 * 获取电话详情列表列表
	 * 
	 * @return
	 */
	@RequestMapping(value = "telBookInfoList/{telBookId}", method = RequestMethod.POST)
	public List<TelBookInfo> telBookInfo(@PathVariable("telBookId") String telBookId) {
		return telBookInfoService.selectTelBookInfoByTelBookId(telBookId);
	}
	
	/**
	 * 添加电话详情列表
	 * 
	 * @return
	 */
	@RequestMapping(value = "telBookInfoList/insert", method = RequestMethod.POST)
	public String insertTelBookInfo(@RequestParam("telBookStr") String telBookStr) {
		return telBookInfoService.insertTelBookInfo(telBookStr) ? SystemConstants.Code.SUCCESS : SystemConstants.Code.FAIL;
	}
	
	/**
	 * 查看当前电话薄中fuserid的详细信息
	 * 
	 * @return
	 */
	@RequestMapping(value = "getTelBookInfo/{telBookId}/{fuserid}", method = RequestMethod.POST)
	public TelBookInfo getTelBookInfoByFuserid(@PathVariable("telBookId") String telBookId, @PathVariable("fuserid") String fuserid) {
		return telBookInfoService.getTelBookInfoByFuserid(telBookId, fuserid);
	}
	
	/**
	 * 修改电话详情列表
	 * 
	 * @return
	 */
	@RequestMapping(value = "updateTelBookInfo", method = RequestMethod.POST)
	public String updateTelBookInfo(@RequestParam("telBookInfoStr") String telBookInfoStr) {
		return telBookInfoService.updateTelBookInfo(telBookInfoStr) ? SystemConstants.Code.SUCCESS : SystemConstants.Code.FAIL;
	}
	
	/**
	 * 删除电话详情列表
	 * 
	 * @return
	 */
	@RequestMapping(value = "deleteTelBookInfo/{telBookInfoId}", method = RequestMethod.POST)
	public String deleteTelBookInfo(@PathVariable("telBookInfoId") String id) {
		return telBookInfoService.deleteTelBookInfo(id) ? SystemConstants.Code.SUCCESS : SystemConstants.Code.FAIL;
	}
}
